import { nextTick, ref } from 'vue'
import { defineStore } from 'pinia'
import Cookies from 'js-cookie'

export const useAppStore = defineStore('app', () => {
  // 是否水平折叠收起菜单
  const asideIsCollapse = ref(Cookies.get('asideIsCollapse') === '1' ? true : false)
  // 全局尺寸
  const size = ref<string>(Cookies.get('size') || 'default')
  // 思维导图方向
  const rankdir = ref<string>('LR') // 'LR' | 'RL' | 'TB' | 'BT'
  // 是否显示
  const isShow = ref<boolean>(true)
  // 是否重新加载
  function isReload() {
    isShow.value = false
    nextTick(() => {
      isShow.value = true
    })
  }

  return { asideIsCollapse, size, rankdir, isShow, isReload }
})
